package com.jinyi.wwdeng.ui.tab.home

import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import com.jinyi.base.base.BaseFragment
import com.jinyi.base.utils.BarUtils
import com.jinyi.wwdeng.databinding.FragmentHomeBinding
import com.jinyi.wwdeng.ui.config.act.ConfigAct

/**
 * JinYiTest
 * @Author wwdeng
 * @CreateTime: 2024/4/17 14:34
 * @Annotation：首页
 */
class HomeFragment: BaseFragment() {

    lateinit var binding: FragmentHomeBinding

    override fun getRootView(inflater: LayoutInflater): View {
        binding = FragmentHomeBinding.inflate(inflater)
        return binding.root
    }

    override fun initView() {
        binding.parentLayout.setPadding(0,BarUtils.getStatusBarHeight(),0,0)
        initRefreshLayout()
    }

    override fun initListener() {
        //Check
        binding.includeType2.btnCheck.setOnClickListener {
            onIntent(ConfigAct::class.java)
        }
    }

    override fun initData() {
    }


    /* 初始化刷新 */
    private fun initRefreshLayout() {
        //禁止加载
        binding.refreshLayout.setEnableLoadMore(false)
        binding.refreshLayout.setEnableAutoLoadMore(false)
        binding.refreshLayout.setOnRefreshListener {
            Handler().postDelayed({
                binding.refreshLayout.finishRefresh()
            },1000)
        }
        binding.refreshLayout.setOnLoadMoreListener {
            binding.refreshLayout.finishLoadMore()
        }
    }
}